# @Time : 2021/10/25 20:52
# @Author : Li Kunlun
# @Description : 使用线程池在web服务中实现加速

import flask
import json
import time

app = flask.Flask(__name__)


def read_file():
    time.sleep(0.1)
    return "read_file result"


def read_db():
    time.sleep(0.2)
    return "read_db result"


def read_api():
    time.sleep(0.3)
    return "read_api result"


@app.route("/")
def index():
    result_file = read_file()
    result_db = read_db()
    result_api = read_api()
    return json.dumps({
        "result_file": result_file,
        "result_db": result_db,
        "result_api": result_api
    })


if __name__ == '__main__':
    app.run()
